{extend name="layout/layout" /}

{block name="pagecss"}
<link href="__STATIC__/plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
<link href="__STATIC__/plugins/select2/css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" />
{/block}

{block name="content"}
<div class="row">
    <div class="col-md-12">
        <div class="portlet light">
            <div class="portlet-title">
                <div class="caption">
                    <i class="icon-share font-dark"></i>
                    <span class="caption-subject font-dark bold uppercase">新增政策享受 </span>
                </div>
                <div class="actions">
                    <a class="btn btn-circle btn-icon-only btn-default fullscreen" href="javascript:;" data-original-title="" title=""> </a>
                </div>
            </div>
            <div class="portlet-body">
                <form id="ajax-form" class="form-horizontal" method="post" enctype="multipart/form-data">
                    <div class="form-body">
                        <div class="row" style="margin-bottom: 10px;">
                            <div class="col-md-9">
                                <div class="form-inline">
                                    <label class="control-label col-md-3">
                                        选择乡村
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <input class="city" type="hidden" name="cityId" value="{$povertypolicyledger.cityId}">
                                        <input class="xian" type="hidden" name="xianId" value="{$povertypolicyledger.xianId}">
                                        <input class="town" type="hidden" name="townId" value="{$povertypolicyledger.townId}">
                                        <input class="village" type="hidden" name="villageId" value="{$povertypolicyledger.villageId}">
                                        <p class="form-control-static"> {$area} </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        贫困户
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-4">
                                        <!--<select class="form-control select2-data-ajax" name="householderId">
                                            <option value="0" selected="selected">请输入户主名</option>
                                        </select>-->
                                        <button class="form-control select-householder" type="button" data-title="选择户主">选择户主</button>
                                        <input type="hidden" name="householderId" value="">
                                    </div>
                                    <div class="col-md-4">
                                        <button class="form-control select-member" type="button" data-title="选择家庭成员">选择家庭成员</button>
                                        <input type="hidden" name="memberId" value="">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="policy-group">
                        {foreach name="policyList" item="policys" key="policysKey"}
                            <div class="row policy-div">
                                <div class="col-md-9">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            {:show_policys($policys.policyType)}
                                            <!--<span class="required">*</span>-->
                                        </label>
                                        <input type="hidden" class="" name="policyType" value="{$policys.policyType}">
                                        <div class="col-md-9">
                                            {foreach name="policys.policySpec" item="policySpec" key="policySpecKey"}
                                                <div class="row policySpec-div" {if condition="($policySpecKey > 0)"}style="margin-top: 20px;"{/if}>
                                                    {if condition="($policySpec.specType != 0)"}
                                                        <div class="col-md-2">
                                                            <label class="control-label">
                                                                {$povertypolicyledger.year}年
                                                                {if condition="($policySpec.specType == 1)"}
                                                                    {:show_quarter($policySpec.quarter)}
                                                                {else /}
                                                                    {:show_month($policySpec.month)}
                                                                {/if}
                                                            </label>
                                                        </div>
                                                    {/if}
                                                    <input type="hidden" class="spec-type" name="specType" value="{$policySpec.specType}">
                                                    <div class="col-md-2 quarter-div hide">
                                                        <input type="hidden" class="quarter" name="quarter" value="{$policySpec.quarter}">
                                                    </div>
                                                    <div class="col-md-2 month-div hide">
                                                        <input type="hidden" class="month" name="month" value="{$policySpec.month}">
                                                    </div>
                                                    <div class="col-md-2 explain-div hide">
                                                        <input type="hidden" class="explain" name="explain" value="{$policySpec.explain}">
                                                    </div>
                                                    {if condition="($policySpec.explain == 1)"}
                                                        <div class="col-md-4">
                                                            <input type="text" class="form-control explain-value" data-type="amount" name="explainValue" value="" placeholder="输入金额" >
                                                        </div>
                                                        <span class="help-inline">元</span>
                                                    {else /}
                                                        <div class="col-md-6">
                                                            <input type="text" class="form-control explain-value" data-type="text" name="explainValue" value="" maxlength="40" placeholder="输入说明" >
                                                        </div>
                                                    {/if}
                                                </div>
                                            {/foreach}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        {/foreach}
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        备注
                                    </label>
                                    <div class="col-md-9">
                                        <input type="text" class="form-control" placeholder="备注，最多80字" maxlength="80" data-required="{$povertypolicyledger.isRemark}" name="remark" value="">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <input type="hidden" name="id" value="">
                        <input type="hidden" class="form-control" name="policyledgerId" value="{$ledgerId}">
                        <input type="hidden" class="form-control" name="ledgerId" value="{$ledgerId}">

                        <hr />
                        <div class="row">
                            <div class="form-actions">
                                <div class="col-md-offset-2 col-md-10">
                                    <button type="button" id="form-submit" class="btn blue save-btn">
                                        保存 <i class="fa fa-floppy-o"></i>
                                    </button>
                                    <button type="button" class="btn default" onclick="history.go(-1);">
                                        返回 <i class="fa fa-mail-forward"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- 成员 模态框 -->
<div class="modal fade" id="member-modal" data-backdrop="static" data-keyboard="false" >
    <div class="modal-dialog" style="width:800px; height: 520px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">x</button>
                <h4 class="modal-title">成员</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <div class="portlet light" style="margin-bottom: 0;">
                            <div class="box-header">
                                <div class="row">
                                    <div class="col-md-10">
                                        <form id="searchForm" action="" class="form" method="post">
                                            <div class="form-inline">
                                                <input type="text" class="form-control" name="name" value="" placeholder="姓名">
                                                &nbsp;&nbsp;&nbsp;
                                                <button id="doSearch" type="button" class="btn btn-success" title="搜索">
                                                    <i class="fa fa-search"></i> 搜索
                                                </button>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                            <div class="portlet-body">
                                <form class="form-horizontal" action="" name="ajaxForm">
                                    <div class="">
                                        <table id="member-datatable" class="table table-bordered table-hover dataTable">
                                            <thead>
                                            <th>头像</th>
                                            <th>姓名</th>
                                            <th>性别</th>
                                            <th>操作</th>
                                            </thead>
                                        </table>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <!--<button type="button" class="btn blue saveMember-btn"> 确定 </button>-->
                <button type="button" class="btn default" data-dismiss="modal"> 关闭 </button>
            </div>
        </div>
    </div>
</div>

<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/savepost')}">
<input type="hidden" class="memberDatalist_url" value="{:url('admin/'.strtolower($model).'/memberlist')}">

<input type="hidden" class="ajax_member_url" value="{:url('admin/layer/ajaxMembers')}">
<input type="hidden" class="householder_member_url" value="{:url('admin/layer/householderList')}">
{/block}

{block name="pagescript"}
<script src="__STATIC__/plugins/select2/js/select2.full.min.js" type="text/javascript"></script>
<script src="__STATIC__/plugins/select2/js/i18n/zh-CN.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/povertypolicy.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/select_member.js" type="text/javascript"></script>
{/block}